package com.coolbi.onsupai.core.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.onsupai.core.dao.GoodsCategoryDao;
import com.coolbi.onsupai.core.entity.GoodsCategory;
import com.coolbi.onsupai.core.mapper.GoodsCategoryMapper;

public class GoodsCategoryDaoImpl implements GoodsCategoryDao {

	@Autowired
	private GoodsCategoryMapper goodsCategoryMapper;
	
	@Override
	public GoodsCategory save(GoodsCategory obj) {
		goodsCategoryMapper.save(obj);
		return obj;
	}

	@Override
	public int delete(long id) {
		return goodsCategoryMapper.delete(id);
	}

	@Override
	public int update(GoodsCategory obj) {
		return goodsCategoryMapper.update(obj);
	}

	@Override
	public GoodsCategory get(long id) {
		return goodsCategoryMapper.get(id);
	}

	@Override
	public List<GoodsCategory> list() {
		return goodsCategoryMapper.list();
	}

	@Override
	public List<GoodsCategory> listByPage(int offset, int limit) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return goodsCategoryMapper.listByPage(parameter);
	}

	@Override
	public List<GoodsCategory> find(Map<String, Object> parameter) {
		return goodsCategoryMapper.listByParameter(parameter);
	}

	@Override
	public List<GoodsCategory> findByPage(Map<String, Object> parameter,
			int offset, int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return goodsCategoryMapper.listByParameterPage(parameter);
	}

	@Override
	public List<GoodsCategory> search(Map<String, Object> parameter,
			int offset, int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return goodsCategoryMapper.search(parameter);
	}

	@Override
	public int count() {
		return goodsCategoryMapper.count();
	}

	@Override
	public int countByKeyWord(Map<String, Object> parameter) {
		return goodsCategoryMapper.countByKeyWord(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return goodsCategoryMapper.countByParameter(parameter);
	}

	public void setGoodsCategoryMapper(GoodsCategoryMapper goodsCategoryMapper) {
		this.goodsCategoryMapper = goodsCategoryMapper;
	}

	@Override
	public int countByCategoryName(String categoryName) {
		return goodsCategoryMapper.countByCategoryName(categoryName);
	}

}
